from django.shortcuts import render
from django.http import HttpResponse
from django.core.urlresolvers import reverse
from models import MobliePage
# Create your views here.


class CtxMobile(object):
    def __init__(self,user):
        self.pages=[]
        self.mobile_url=reverse('mobile')
        self_user=user
    
    def build(self):
        self.build_pages()
    
    def build_pages(self):
        self.pages=MobliePage.objects.all()
    
    
    

def mobile(request):
    ctx= CtxMobile(request.user)
    ctx.build()
    return render(request,'mobile.html',context=ctx.__dict__)

def mobile_page(request,page):
    page=MobliePage.objects.filter(pk=page).first()
    return HttpResponse(page.long_dsp)